<?php

namespace App\Providers;

use App\Http\Models\Admin\ProductCategory;
use App\Http\Models\ArticleTag;
use App\Http\Models\Video;
use App\Http\Models\VideoType;
use App\Presenters\GlobalViewPresenter;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        $this->extendBlade();

        // 共享页脚的数据
//        View::share('footer', $this->getFooterData());
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }

    /**
     * 扩展blade语法用于调试
     */
    private function extendBlade()
    {
        Blade::directive('json', function ($data) {
            return "<?php header('Content-Type: application/json');echo json_encode($data); die(); ?>";
        });

        Blade::directive('die', function () {
            return "<?php die() ?>";
        });

        Blade::directive('dd', function ($data) {
            return "<?php dd($data) ?>";
        });
    }
}
